package com.only4play.practice.invoice.core.entity;

import com.only4play.codegen.processor.api.*;
import com.only4play.codegen.processor.controller.GenController;
import com.only4play.codegen.processor.creator.GenCreator;
import com.only4play.codegen.processor.dto.GenDto;
import com.only4play.codegen.processor.entitymapper.GenObjectMapper;
import com.only4play.codegen.processor.mapper.GenMapper;
import com.only4play.codegen.processor.query.GenQuery;
import com.only4play.codegen.processor.service.GenService;
import com.only4play.codegen.processor.service.GenServiceImpl;
import com.only4play.codegen.processor.updater.GenUpdater;
import com.only4play.codegen.processor.vo.GenVo;
import com.only4play.codegen.support.model.BaseEntity;
import com.only4play.codegen.support.annotation.FieldDesc;
import com.only4play.codegen.support.constants.ValidStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;

/**
 * 企业主体
 */
@GenCreator(pkgName = "com.only4play.practice.invoice.api.model.creator")
@GenUpdater(pkgName = "com.only4play.practice.invoice.api.model.updater")
// findById方法
@GenVo(pkgName = "com.only4play.practice.invoice.api.model.vo")
// findByPage方法
@GenQuery(pkgName = "com.only4play.practice.invoice.api.model.query")
@GenCreateRequest(pkgName = "com.only4play.practice.invoice.model.api.request")
@GenUpdateRequest(pkgName = "com.only4play.practice.invoice.model.api.request")
@GenQueryRequest(pkgName = "com.only4play.practice.invoice.model.api.request")
@GenResponse(pkgName = "com.only4play.practice.invoice.api.model.api.response")
@GenDto(pkgName = "com.only4play.practice.invoice.model.dto")
// 生成serviceImpl
@GenObjectMapper(pkgName = "com.only4play.practice.invoice.core.entitymapper")
// 生成serviceImpl
@GenMapper(pkgName = "com.only4play.practice.invoice.core.mapper")
@GenService(pkgName = "com.only4play.practice.invoice.core.service")
@GenServiceImpl(pkgName = "com.only4play.practice.invoice.core.service.impl")

@GenController(pkgName = "com.only4play.practice.invoice.core.controller")
@GenFeign(pkgName = "com.only4play.practice.invoice.feign")


@EqualsAndHashCode(callSuper = true)
@Data
public class EnterpriseEntity extends BaseEntity {

  @FieldDesc(name = "税务编码") // 每个企业唯一
  private String taxCode;

  /**************企业基本信息***************/

  @FieldDesc(name = "社会信用号")
  private String creditNo;

  @FieldDesc(name = "企业名称")
  private String enterpriseName;

  @FieldDesc(name = "纳税人识别号")
  private String taxNo;

  @FieldDesc(name = "注册地址")
  private String registerAddress;

  @FieldDesc(name = "注册电话")
  private String registerPhone;

  @FieldDesc(name = "开户银行")
  private String openBank;

  @FieldDesc(name = "银行账户")
  private String bankAccount;

  @FieldDesc(name = "增值税普通发票金额最小值")
  private Long generalInvoiceMinLimit;

  @FieldDesc(name = "增值税普通发票金额最大值")
  private Long generalInvoiceMaxLimit;

  @FieldDesc(name = "电子发票金额最小值")
  private BigDecimal electronicInvoiceMinLimit;

  @FieldDesc(name = "电子发票金额最大值")
  private BigDecimal electronicInvoiceMaxLimit;

  @FieldDesc(name = "增值税专用发票金额最小值")
  private Long specialInvoiceMinLimit;

  @FieldDesc(name = "增值税专用发票金额最大值")
  private Long specialInvoiceMaxLimit;

  private ValidStatus validStatus;

  public void init() {
    setValidStatus(ValidStatus.VALID);
  }

  public void valid(){
    setValidStatus(ValidStatus.VALID);
  }

  public void invalid(){
    setValidStatus(ValidStatus.INVALID);
  }
}
